package com.yc.cloud.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yc.cloud.common.orm.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalTime;

/**
 * <p>
 * 摄像头时间段配置表（录像、抓拍通用）
 * </p>
 *
 * @author kinggu
 * @since 2025-10-14
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("hw_camera_time_slot")
public class HwCameraTimeSlot extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 时间段名称
     */
    @TableField("slot_name")
    private String slotName;

    /**
     * 开始时间（HH:mm:ss）
     */
    @TableField("start_time")
    private LocalTime startTime;

    /**
     * 结束时间（HH:mm:ss）
     */
    @TableField("end_time")
    private LocalTime endTime;

    /**
     * 生效星期，逗号分隔：1,2,3,4,5,6,7（周一到周日）
     */
    @TableField("days_of_week")
    private String daysOfWeek;

    /**
     * 时间段描述
     */
    @TableField("description")
    private String description;

    /**
     * 时间段状态：0-禁用，1-启用
     */
    @TableField("status")
    private Byte status;

    /**
     * 逻辑删除标志：0-未删除，1-已删除
     */
    @TableField("is_deleted")
    private Byte isDeleted;

    // 字段常量定义（用于 QueryWrapper 构建查询）
    public static final String SlotName = "slot_name";
    public static final String StartTime = "start_time";
    public static final String EndTime = "end_time";
    public static final String DaysOfWeek = "days_of_week";
    public static final String Description = "description";
    public static final String Status = "status";
    public static final String IsDeleted = "is_deleted";

    /**
     * 判断是否为跨日时间段
     * @return true-跨日，false-不跨日
     */
    public boolean isCrossDay() {
        if (startTime == null || endTime == null) {
            return false;
        }
        return startTime.isAfter(endTime);
    }
}

